package com.imti.mall.user.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.imti.mall.common.Api.CommonResult;
import com.imti.mall.model.pms.pojo.PmsProduct;
import com.imti.mall.model.user.pojo.UmsMember;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Service;

@Mapper
public interface UserMemberMapper extends BaseMapper<UmsMember> {

    /**
     * 检验手机号是否使用过
     * @param phone 手机号
     * @return int
     *
     */
    @Select("select count(*) from ums_member where phone=#{phone}")
    public int findPhone(String phone);

    /**
     * 向用户列表中添加用户信息
     * @param umsMember
     * @return Integer
     */
    @Insert("insert into ums_member (username,password,phone) values(#{username},MD5(#{password}),#{phone})")
    public Integer saveMember(UmsMember umsMember);

    /**
     * 二、登录
     */
    @Select("SELECT ums.username,ums.password,ums.phone FROM ums_member ums where ums.username=#{username} and ums.password=MD5(#{password}) and ums.phone=#{phone}")
    public UmsMember logins(UmsMember umsMember);

    /**
     * 找回密码
     */

    @Update("update ums_member set password=MD5(#{password}) where phone=#{phone}")
    public int changePwd(UmsMember umsMember);
}
